﻿using UnityEngine;
using System.Collections;

public class scStageBox : MonoBehaviour {

	private int stageLevel = 0;
	public Sprite [] starsSprite = new Sprite[3];


	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
	}
	
	void OnMouseDown()
	{
		Debug.Log ("you choice level = " + stageLevel);

		Application.LoadLevel("level_" + stageLevel);
	}

	void InitStars(int level)
	{
		stageLevel = level;

		int stars = scPlayerInfo.GetStars(level);
		if (stars == 0)
		{
			return;
		}

		SpriteRenderer [] childGameObjects = GetComponentsInChildren<SpriteRenderer>();
		foreach (SpriteRenderer gameObj in childGameObjects)
		{
			if (gameObj.name == "Stars")
			{
				gameObj.sprite = starsSprite[stars - 1];
				return;
			}
		}
	}
}
